import common.CommonFunction;
import common.Mask;

import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.events.MouseEvent;
import flash.net.FileReference;
import flash.ui.Keyboard;

import mx.controls.Alert;
import mx.events.CloseEvent;
import mx.events.ListEvent;
import mx.managers.PopUpManager;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;

public var infoObject:Object;

protected function titlewindow2_keyDownHandler(event:KeyboardEvent):void
{
	if(event.charCode == Keyboard.ESCAPE)
	{
		PopUpManager.removePopUp(this);
	}	
}

protected function cancel_clickHandler(event:MouseEvent):void
{
	PopUpManager.removePopUp(this);	
}

public function onSuccess(event:ResultEvent):void
{
	
}

public function onFailure(event:FaultEvent):void
{
	Mask.close();
	Alert.show(event.message + "");
}

public var fileReference:FileReference = new FileReference();
public function init():void
{
	fileReference.addEventListener(Event.OPEN, callUpload);
}

public function callUpload(event:Event):void
{
	Alert.show(event.target.name + "");
	imgPath.text = event.target.nativePath;
}

protected function img_path_clickHandler(event:MouseEvent):void
{
	fileReference.browse();	
}

protected function country_changeHandler(event:ListEvent):void
{
	state.dataProvider = groupDB.country.(@name == country.selectedLabel).state.@name;
}

protected function state_changeHandler(event:ListEvent):void
{
	city.dataProvider = groupDB.country.(@name == country.selectedLabel).state.(@name == state.selectedLabel).city;
}

protected function update_clickHandler(event:MouseEvent):void
{
	infoObject = new Object();
	infoObject["date"] = new Date();
	infoObject["empName"] = empName.text;
	updateEmpProfile.send(infoObject);
}
